package com.api.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;



// @Configuration  使用WebMvcConfigurationSupport这个会将返回date类型的数据 转回家为时间戳
@Configuration
public class CorsConfig implements WebMvcConfigurer{ // extends WebMvcConfigurerAdapter
    // static final String ORIGINS[] = new String[] { "GET", "POST", "PUT", "DELETE" };
    // @Override
    // public void addCorsMappings(CorsRegistry registry) {
    //     registry.addMapping("/**")
    //             .allowCredentials(true)
    //             .allowedOriginPatterns("*")
    //             .allowedMethods(ORIGINS)
    //             .maxAge(3600);
    // }
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //配置拦截器访问静态资源
        registry.addResourceHandler("/doc.html","/swagger-ui.html")
                .addResourceLocations("classpath:/META-INF/resources/");
        registry.addResourceHandler("/favicon.ico")
                .addResourceLocations("classpath:/META-INF/resources/");
        registry.addResourceHandler("/webjars/**")
                .addResourceLocations("classpath:/META-INF/resources/webjars/");
        registry.addResourceHandler("/v3/**")
                .addResourceLocations("classpath:/META-INF/resources/v3/");
    }
}
